// 全局共用效果js

$(function(){
	// sidebar
	$("body").on('click','.nav-parent-title',function(){
    // $(".nav-parent-title").click(function(){
        $(this).siblings('.nav-children').slideToggle(500);
        $(this).parent().siblings().find('.nav-children').slideUp(500);
        $(this).parent().addClass("active").siblings().removeClass("active");
        if($(this).find('.iconRight').hasClass("fa-angle-down")){
          $(this).find('.iconRight').removeClass("fa-angle-down").addClass("fa-angle-up");
          $(this).parent().siblings().find('.nav-parent-title .iconRight').removeClass("fa-angle-up").addClass("fa-angle-down");
        }else{
          $(this).find('.iconRight').removeClass("fa-angle-up").addClass("fa-angle-down");
        }
    })

    // 登录信息设置
	$("body").on('click','.clearfix[data-toggle="popover"]',function(){
        $(this).popover({
            'title':'',
            'html':true,
            'delay': { "show": 500, "hide": 100},
            'trigger':'focus',
            'placement':'bottom',
            'content': '<ul class="login-settings-list">'+
                            '<li><a href="javascript:;"><i class="fa fa-gear"></i>系统设置</a></li>'+
                            '<li><a href="javascript:;"><i class="fa fa-power-off"></i>退出</a></li>'+
                        '</ul>'
        }).popover('show');
    })


	// 删除效果
	$(".delete-btn").attr("data-toggle","modal");
	$(".delete-btn").attr("data-target","#delModal");
	$(".delete-btn").click(function(){
		if(!$("#delModal").hasClass("bs-example-modal-sm")){
			$("body").append('<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="delModal">'+
						        '<div class="modal-dialog modal-sm">'+
							        '<div class="modal-content">'+
							          '<div class="modal-header modal-header-sm">'+
							            '<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>'+
							            '<h4 class="modal-title" id="myModalLabel">删除提示</h4>'+
							          '</div>'+
							          '<div class="modal-body">'+
							             '<p class="prompt-text">您确定删除所选项？<br/>删除后无法恢复</p>'+
							          '</div>'+
							          '<div class="modal-footer modal-footer-sm">'+
							            '<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>'+
							            '<button type="button" class="btn checkedBtn">确定</button>'+
							          '</div>'+
							        '</div>'+
						        '</div>'+
						    '</div>');
		}
	    modalLocation();
	})

	// 计算删除弹出框位置
	function modalLocation(){
		var wHeight = $(window).height();
		var moveTop = (wHeight-225)/2-60;
		$("#delModal .modal-content").css("margin-top",moveTop+"px");
	}
	
})

